lib/repo: Omit deltas from the summary file if there are none
authorPhilip Withnall <withnall@endlessm.com>
Wed, 7 Jun 2017 13:32:29 +0000 (14:32 +0100)
committerAtomic Bot <atomic-devel@projectatomic.io>
Wed, 7 Jun 2017 16:55:35 +0000 (16:55 +0000)
If there are no deltas to be listed in the summary file, don’t bother
including the key for them in the additional metadata section of the
file. This saves a few bytes in some cases.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #911
Approved by: cgwalters

src/libostree/ostree-repo.c
tests/test-summary-view.sh

index c1aedb91d6d8473e52f0ad52961318868772eed8..0d20c25bd0281155ec76f9ff757aa57a8940772f 100644 (file)
@@ -4561,7 +4561,8 @@ ostree_repo_regenerate_summary (OstreeRepo     *self,
         g_variant_dict_insert_value (&deltas_builder, delta_names->pdata[i], ot_gvariant_new_bytearray (csum, 32));
       }
 
-    g_variant_dict_insert_value (&additional_metadata_builder, OSTREE_SUMMARY_STATIC_DELTAS, g_variant_dict_end (&deltas_builder));
+    if (delta_names->len > 0)
+      g_variant_dict_insert_value (&additional_metadata_builder, OSTREE_SUMMARY_STATIC_DELTAS, g_variant_dict_end (&deltas_builder));
   }
 
   {
index 5b52b6911f7ceb492f3d8e41dfe252c723464228..60855eb100f6d9354287c6a9586276818edd3815 100755 (executable)
@@ -51,7 +51,6 @@ ${OSTREE} summary --view > summary.txt
 assert_file_has_content_literal summary.txt "* main"
 assert_file_has_content_literal summary.txt "* other"
 assert_file_has_content_literal summary.txt "ostree.summary.last-modified"
-assert_file_has_content_literal summary.txt "Static Deltas (ostree.static-deltas): {}"
 assert_file_has_content_literal summary.txt "Timestamp (ostree.commit.timestamp): "
 echo "ok view summary"